<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:comps="http://java.sun.com/jsf/composite/components">

<f:view contentType="text/html">
	
	<f:loadBundle basename="com.jpress.locale.locale_pt" var="locale" />
	
	<h:head>
	
		<f:facet name="first">
		
			<meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />
			
			<title>
				<h:outputText value="#{locale['sistema.nome']} #{locale['sistema.ano']} - #{locale['sistema.navegacao.inicio']}"  /> 
			</title> 
			
		</f:facet>
		
		<h:outputStylesheet library="css" name="estilos.css" />
		<link rel="shortcut icon" type="image/x-icon" href="./resources/images/favicon.ico" />
		
		<h:outputScript library="js" name="stringsUtils.js" target="head" />
		<h:outputScript library="js" name="locale-primefaces.js" />
		
	</h:head>
	
	<h:body>
	
		<p:growl id="indexGrowl" sticky="true" />
		<ui:debug hotkey="K" />
		
		<h:panelGroup layout="block" styleClass="cabecalho">
		
			<h:panelGroup layout="block" styleClass="container">
		
				<h:panelGroup layout="block" styleClass="left">
					
					<h:graphicImage library="images/sistema" name="logo-mini.png"
						rendered="#{!SessaoBean.autenticado}"
						styleClass="logoMini" />
						
					<h:form id="logoForm" prependId="false" rendered="#{SessaoBean.autenticado}">						
						
						<h:commandLink action="#{SessaoBean.navegarInicio()}">
							<h:graphicImage library="images/sistema" name="logo-mini.png"
								title="#{locale['sistema.voltarInicio']}"
								styleClass="logoMini" />
						</h:commandLink>
								
					</h:form>			
						
				</h:panelGroup>
				
				<h:panelGroup layout="block" styleClass="right cabecalhoInformacao" rendered="#{!SessaoBean.autenticado}">
				
					<p:commandButton id="loginBtn" 
						value="#{locale['sistema.botao.autenticar']}"
						type="button"
						onclick="loginDlg.show();" />
				
				</h:panelGroup>
				
				<h:panelGroup layout="block" styleClass="right cabecalhoInformacao" rendered="#{SessaoBean.autenticado}">
					
					<h:panelGrid id="cabecalho" columns="2">
						
						<h:panelGrid columns="1" styleClass="info-nome-funcao">
							
							<h:outputText value="#{SessaoBean.usuarioAutenticado.nome}" />
							<h:outputText value="#{SessaoBean.usuarioAutenticado.blog.nome}" />
									
						</h:panelGrid>
								
						<p:commandLink id="maisInfoLnk">
							 <p:graphicImage value="resources/images/usuarios/#{SessaoBean.usuarioAutenticado.avatar}" width="26" height="26" />
						</p:commandLink>
						
					</h:panelGrid>
			
				</h:panelGroup>
				
			</h:panelGroup>	
		
		</h:panelGroup>
		
		<h:panelGroup layout="block" style="background-color: red;" >
			<h:outputFormat value="teste" />
		</h:panelGroup>
		
		<h:form id="cadastrosForm">
		
			<p:commandButton id="cadastrarBtn"
				value="#{locale['cadastro.botao.novaConta']}"
				update=":cadastroForm"
				action="#{PaginaInicialBean.prepararCadastro()}" />
				
			<p:commandButton id="cadastrarNewsletterBtn"
				value="#{locale['cadastro.botao.cadastrarNewsletter']}"
				update=":cadastroNewsletterForm"
				action="#{PaginaInicialBean.prepararCadastroNewsletter()}" />			
		
		</h:form>
			
		<p:dialog id="cadastrarDialogo"
			resizable="false" closable="false" draggable="false"
			widgetVar="cadastrarDlg"
			showEffect="slide" hideEffect="slide"
			modal="true">
			
			<f:facet name="header">
				<h:outputText value="#{locale['cadastro.janela.titulo']}" />
			</f:facet>
			
			<h:form id="cadastroForm">
			
				<h:panelGroup layout="block" styleClass="cadastroMessages">
					<h:outputText value="#{locale['cadastro.janela.mensagem']}" style="text-align: justify;" />
					<p:spacer height="10" />
					<p:messages id="cadastroMessages" />
				</h:panelGroup>
				
				<h:panelGrid columns="2">
	
					<p:outputLabel id="nomeLbl" for="nome"
						value="#{locale['cadastro.label.nome']}" />
					<p:inputText id="nome"
						required="true"
						requiredMessage="#{locale['cadastro.validacao.requerido.nome']}"
						styleClass="cadastroInputs"
						label="#{locale['cadastro.label.nome']}"
						value="#{PaginaInicialBean.usuarioNovo.nome}"
						maxlength="100">
						<f:validator validatorId="validator.MinimoPalavrasValidator" />
						<f:attribute name="minimoPalavras" value="2" />
					</p:inputText>
						
					<p:outputLabel id="emailLbl" for="email"
						value="#{locale['cadastro.label.email']}" />
					<p:inputText id="email"
						required="true"
						requiredMessage="#{locale['cadastro.validacao.requerido.email']}"
						styleClass="cadastroInputs"
						label="#{locale['cadastro.label.email']}"
						value="#{PaginaInicialBean.usuarioNovo.email}"
						maxlength="100">
						<f:validator validatorId="validator.EmailValidator" />
					</p:inputText>

					<p:outputLabel for="senha1" value="#{locale['cadastro.label.senha']}" />
					<p:password id="senha1" 
						required="true"
						requiredMessage="#{locale['cadastro.validacao.requerido.senha']}"
						styleClass="cadastroInputs"
						match="senha2" 
						validatorMessage="#{locale['cadastro.alterarSenha.naoCorrespondem']}"
						feedback="true"
						inline="true"
						promptLabel="#{locale['cadastro.alterarSenha.senha.prompt']}"
						weakLabel="#{locale['cadastro.alterarSenha.forcaSenha.fraca']}"
						goodLabel="#{locale['cadastro.alterarSenha.forcaSenha.boa']}"
						strongLabel="#{locale['cadastro.alterarSenha.forcaSenha.forte']}"
						value="#{PaginaInicialBean.usuarioNovo.senha}"
						maxlength="32">
						<f:validateLength minimum="8" maximum="32" />
					</p:password>
					
					<p:outputLabel for="senha2" value="#{locale['cadastro.label.senha']}" />
					<p:password id="senha2" 
						required="true"
						requiredMessage="#{locale['cadastro.validacao.requerido.senha']}"
						styleClass="cadastroInputs"
						feedback="true"
						inline="true"
						promptLabel="#{locale['cadastro.alterarSenha.senhaRepetir.prompt']}"
						weakLabel="#{locale['cadastro.alterarSenha.forcaSenha.fraca']}"
						goodLabel="#{locale['cadastro.alterarSenha.forcaSenha.boa']}"
						strongLabel="#{locale['cadastro.alterarSenha.forcaSenha.forte']}"
						value="#{PaginaInicialBean.usuarioNovo.senha}"
						maxlength="32">
						<f:validateLength minimum="8" maximum="32" />
					</p:password>
					
					<p:outputLabel for="sexo" value="#{locale['cadastro.label.sexo']}" />
					<p:selectOneRadio id="sexo"
						required="true"
						requiredMessage="#{locale['cadastro.validacao.requerido.sexo']}"
						styleClass="cadastroInputs"
						value="#{PaginaInicialBean.usuarioNovo.sexo}">
						<f:selectItems value="#{PaginaInicialBean.sexoList}" />
					</p:selectOneRadio>
					
					<p:outputLabel id="dataNascimentoLbl" for="dataNascimento"
						value="#{locale['cadastro.label.dataNascimento']}" />
					<p:calendar id="dataNascimento"
						required="true"
						requiredMessage="#{locale['cadastro.validacao.requerido.dataNascimento']}"
						pattern="dd/MM/yyyy"
						locale="pt_BR"
						mindate="01/01/1900" maxdate="31/12/1994"
						yearRange="c-100:c+100"
						navigator="true"
						value="#{PaginaInicialBean.usuarioNovo.dataNascimento}" showOn="button" />
					
				</h:panelGrid>
				
				<h:panelGroup layout="block" style="text-align: right; margin-top: 10px;">
				
					<p:commandButton id="cadastrarBtn"
						styleClass="ui-priority-primary"
						update="cadastroForm"
						value="#{locale['cadastro.botao.cadastrar.label']}"
						action="#{PaginaInicialBean.cadastrar()}" />
						
					<p:commandButton id="cancelarCadastroBtn"
						update="cadastroForm"
						value="#{locale['cadastro.botao.cancelarCadastro.label']}"
						action="#{PaginaInicialBean.cancelarCadastro()}"
						immediate="true" />
					
				</h:panelGroup>
			
			</h:form>
			
		</p:dialog>
		
		<p:dialog id="cadastrarNewsletterDialogo"
			resizable="false" closable="false" draggable="false"
			widgetVar="cadastrarNewsletterDlg"
			showEffect="slide" hideEffect="slide"
			modal="true">
			
			<f:facet name="header">
				<h:outputText value="#{locale['cadastroNewsletter.janela.titulo']}" />
			</f:facet>
			
			<h:form id="cadastroNewsletterForm">
			
				<h:panelGroup layout="block" styleClass="cadastroNewsletterMessages">
					<h:outputText value="#{locale['cadastroNewsletter.janela.mensagem']}" />
					<p:spacer height="10" />
					<p:messages id="cadastroNewsletterMessages" />
				</h:panelGroup>
				
				<h:panelGrid columns="2">
	
					<p:outputLabel id="nomeNewsletterLbl" for="nomeNewsletter"
						value="#{locale['cadastro.label.nome']}" />
					<p:inputText id="nomeNewsletter"
						required="true"
						requiredMessage="#{locale['cadastroNewsletter.validacao.requerido.nome']}"
						styleClass="cadastroInputs"
						label="#{locale['cadastro.label.nome']}"
						value="#{PaginaInicialBean.pessoaNewsletter.nome}">
						<f:validator validatorId="validator.MinimoPalavrasValidator" />
						<f:attribute name="minimoPalavras" value="2" />
					</p:inputText>
						
					<p:outputLabel id="emailNewsletterLbl" for="emailNewsletter"
						value="#{locale['cadastro.label.email']}" />
					<p:inputText id="emailNewsletter"
						required="true"
						requiredMessage="#{locale['cadastroNewsletter.validacao.requerido.email']}"
						styleClass="cadastroInputs"
						label="#{locale['cadastro.label.email']}"
						value="#{PaginaInicialBean.pessoaNewsletter.email}">
						<f:validator validatorId="validator.EmailValidator" />
					</p:inputText>
					
				</h:panelGrid>
				
				<h:panelGroup layout="block" style="text-align: right; margin-top: 10px;">
				
					<p:commandButton id="cadastrarNewsletterBtn"
						styleClass="ui-priority-primary"
						update="cadastroNewsletterForm"
						value="#{locale['cadastro.botao.cadastrar.label']}"
						action="#{PaginaInicialBean.cadastrarNewsletter()}" />
						
					<p:commandButton id="cancelarNewsletterBtn"
						update="cadastroNewsletterForm"
						value="#{locale['cadastro.botao.cancelar.label']}"
						action="#{PaginaInicialBean.cancelarCadastroNewsletter()}"
						immediate="true" />
						
				</h:panelGroup>
			
			</h:form>
			
		</p:dialog>
		
		<p:dialog id="loginDialogo"
			widgetVar="loginDlg"
			resizable="false" closable="false" draggable="false"
			showEffect="slide" hideEffect="slide"
			modal="true">
			
			<f:facet name="header">
				<h:outputText value="#{locale['login.titulo']}" />
			</f:facet>
			
			<h:form id="loginForm">
			
				<h:panelGroup layout="block" styleClass="loginMessages">
					<p:messages id="loginMessages" />
				</h:panelGroup>
			
				<h:panelGrid columns="2">
				
					<p:outputLabel id="emailLoginLbl"
						for="emailLogin" value="#{locale['login.label.email']}" />
					<p:inputText id="emailLogin"
						required="true"
						maxlength="100"
						size="37"
						value="#{SessaoBean.email}" />
						
					<p:outputLabel id="senhaLoginLbl" 
						for="senhaLogin" value="#{locale['login.label.senha']}" />
					<p:password id="senhaLogin"
						required="true"
						inline="true"
						maxlength="32"
						size="37"
						value="#{SessaoBean.senha}">
						<f:validateLength minimum="8" maximum="32" />
					</p:password>
					
				</h:panelGrid>
				
				<p:spacer height="10" />
			
				<h:panelGroup layout="block" style="text-align: right; margin-top: 10px;">
				
					<p:commandButton id="autenticarBtn"
						styleClass="ui-priority-primary"
						update="loginForm"
						value="#{locale['login.botao.autenticar']}"
						action="#{SessaoBean.autenticar()}"
						oncomplete="javascript:location.reload(true)" />
					
					<p:commandButton id="cancelarAutenticacaoBtn"
						update="loginForm"
						value="#{locale['login.botao.cancelar']}"
						action="#{SessaoBean.cancelarAutenticacao()}"
						immediate="true" />
										
				</h:panelGroup>
			
			</h:form>
			
		</p:dialog>
		
		<h:outputText value="exibir quantos blogs estão cadastrados" />
		<h:outputText value="exibir ultimos blogs cadastrados" />
		<h:outputText value="integrar postagens com twitter" />
		<h:outputText value="menu horizontal com PaginaInterna" />
		<h:outputText value="widgets na tela =)" />
		<h:outputText value="rodape" />
		<h:outputText value="#{PaginaInicialBean.usuariosQuantidade}" />
		<p:dataTable var="usuario" value="#{PaginaInicialBean.ultimosUsuariosCadastrados}">
			<p:column headerText="usuario">
				<h:outputText value="#{usuario.nome}" />
			</p:column>
		</p:dataTable>
			
	</h:body>
	
</f:view>

</html>